package cn.tellfish.studydemo.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class ThreadPoolStop {


    public static void main(String[] args) {

        ExecutorService pool = Executors.newFixedThreadPool(5);


        for (int i = 0; i < 30; i++) {
            pool.execute(() -> {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("asdfasdfasdfasdfasdf");
            });
        }
        pool.shutdown();
        try {
            pool.awaitTermination(30, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }
}
